<template>
  <view style="width: 651.923rpx; height: 557.692rpx">
    <l-echart ref="chart"></l-echart>
  </view>
</template>

<script>
import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue';
import * as echarts from 'echarts'
import { useReportStore } from '@/stores'
export default {
  components: {LEchart},
  data() {
    return {
      report: {},
      heartListX: [],
      heartListY: [],
      breathListY: [],
      /*  option: {
        xAxis: {
          type: 'time',
          data: this.heartListX,
        },
        yAxis: {
          type: 'value',
        },
        series: [
          {
            data: this.heartListY,
            type: 'line',
            smooth: true,
          },
        ],
      }, */
      option: {
        xAxis: {
          type: 'category',
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
        },
        yAxis: {
          type: 'value',
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147, 260],
            type: 'line',
          },
        ],
      },
    }
  },
  created() {
    this.report = useReportStore().report
    this.handleData()
    //console.log(this.report)
  },
  mounted() {
    this.$refs.chart.init(echarts, (chart) => {
      chart.setOption(this.option)
    })
  },
  methods: {
    handleData() {
      this.report.heartInfo.pictureDataList.forEach((item) => {
        item.coordinateList.forEach((i) => {
          this.heartListX.push(i.xvalue)
          this.heartListY.push(i.yvalue)
        })
      })
      this.report.breathInfo.pictureDataList.forEach((item) => {
        item.coordinateList.forEach((i) => {
          this.breathListY.push(i.yvalue)
        })
      })
      /*  console.log(this.heartListX)
      console.log(this.heartListY)
      console.log(this.breathListY) */
    },
  },
}
</script>
